<!DOCTYPE HTML>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
	<meta http-equiv="Cache-Control" content="no-siteapp"/>
	<link rel="Bookmark" href="../../imgs/bai.ico">
	<link rel="Shortcut Icon" href="../../imgs/bai.ico"/>
	<link rel="stylesheet" type="text/css" href="../../css/static/H-ui.min.css"/>
	<link rel="stylesheet" type="text/css" href="../../css/static/H-ui.admin.css"/>
	<link rel="stylesheet" type="text/css" href="../../css/lib/iconfont.css"/>
	<link rel="stylesheet" type="text/css" href="../../css/views.css"/>
	<title>管理后台</title>
	<style type="text/css">
		#tableMore { cursor: pointer; display: none; }
		#tableMore:hover { background: #F8F8F8; font-weight: bolder; }
		.select { margin-left: 20px; padding: 5px 10px; }
	</style>
</head>
<body>
	<nav class="breadcrumb">
		<a href="javascript:;" class="maincolor" onclick="toHome();">
			<i class="Hui-iconfont">&#xe67f;</i> 首页
		</a>
		<span class="c-gray en">&gt;</span>订单管理
	</nav>
	<div class="Hui-article">
		<article class="cl pd-20">
			<!--<div class="cl pd-5 bg-1 bk-gray mt-20">-->
			<div class="cl pd-5 bg-1 bk-gray">
				<span class="l">
					<a href="shop1.html" class="btn btn-primary radius">
						返回
					</a>
				</span>
				<span class="l">
					<select class="select" id="shopSel" onchange="getIndexByWord(this.value);">
						<option value="0">-选择门店-</option>
					</select>
				</span>
			</div>
			<div class="mt-20">
				<table class="table table-border table-bordered table-hover table-bg table-sort">
					<thead>
					<tr class="text-c">
						<th width="50">ID</th>
						<th width="100">门店</th>
						<th width="100">订单号</th>
						<th width="100">用户</th>
						<th width="100">数量*金额</th>
						<th width="70">下单时间</th>
						<!--<th width="100">操作</th>-->
					</tr>
					</thead>
					<tbody id="formList">
					<tr class="text-c">
						<td colspan="10" style="text-align: center;">没有记录</td>
					</tr>
					</tbody>
				</table>
				<br/>
				<table class="table table-border table-bordered table-hover table-bg table-sort" id="tableMore" onclick="getIndex();">
					<tr class="text-c">
						<td title="点击更多">更多记录</td>
					</tr>
				</table>
			</div>
		</article>
	</div>

	<!-- 表单弹窗 -->
	<span id="formPop"></span>
	<!-- msg弹窗 -->
	<span id="msgPop"></span>
</body>
</html>


<script type="text/javascript" src="../../js/lib/jquery.min.js"></script>
<script type="text/javascript" src="../../js/lib/layer.js"></script>
<script type="text/javascript" src="../../js/static/H-ui.js"></script>
<script type="text/javascript" src="../../js/static/H-ui.admin.page.js"></script>
<script type="text/javascript" src="../../js/config.js"></script>
<script type="text/javascript" src="../../js/view.js"></script>
<!--<script type="text/javascript" src="../../js/views/tmps/shop.js"></script>-->
<script type="text/javascript">
	var formList = {
		data: [],
		pages: {start: 0, limit: 10}
	}; //数据列表
	var word = '';
	(function () {
		getIndex();
		getSelIndex();
	})();
	//搜索
	function getIndexByWord(v){
		formList.pages.start = 0;
		formList.data = [];
		word = v;
		getIndex();
	}
	//列表
	function getIndex(){
		var formData = {
			aid: getAid(),
			shopCode: word,
			pageStart: formList.pages.start,
			pageLimit: formList.pages.limit
		};
		console.log(formData);
		$.ajax({
			type: apis.shop1OrderIndex.method,
			url: domain + apis.shop1OrderIndex.url,
			data: formData,
			success: function (res) {
				console.log(res);
				if (res.code != 0) {
					if (formList.pages.start > 0) {
						msgPop({msg: res.msg});
					}
					var h = '';
					h += '<tr class="text-c">';
					h += '<td colspan="10" style="text-align: center;">没有记录</td>';
					h += '</tr>';
					$('#formList').html(h);
					return
				}
				for (var i = 0; i < res.data.length; i ++) {
					formList.data.push(res.data[i]);
				}
				formList.pages.start ++;
				getHtml();
			},
			error: function () {
				console.log('网络错误');
			}
		});
	}
	//列表字符串
	function getHtml(){
		var h = '', i, d = formList.data;
		h += '';
		for (i = 0; i < d.length; i ++) {
			h += '<tr class="text-c">';
			h += '<td>' + d[i].id + '</td>';
			h += '<td>' + d[i].shopName + '-' + d[i].shop_code + '</td>';
			h += '<td>' + d[i].orderno + '</td>';
			h += '<td>' + d[i].uid + '</td>';
			h += '<td>' + d[i].gnum + '*' + d[i].totalPrice / 100 + '</td>';
			h += '<td>' + d[i].addtime + '</td>';
//			h += '<td class="td-manage">';
//			h += '<a href="javascript:;" title="编辑" class="ml-5" onclick="viewEdit(' + id + ');">';
//			h += '编辑<i class="Hui-iconfont">&#xe6df;</i>';
//			h += '</a> &nbsp;';
//			h += '<a href="' + routes.goods1Index + '?shopCode=' + shopCode + '&shopName=' + escape(shopName) + '" class="ml-5">';
//			h += '商品<i class="Hui-iconfont">&#xe6df;</i>';
//			h += '</a>';
//			h += '</td>';
			h += '</tr>';
		}
		h += '';
		$('#formList').html(h);
		$('#tableMore').show();
	}
	//门店选项
	function getSelIndex(){
		var formData = {
			aid: getAid()
		};
		console.log(formData);
		$.ajax({
			type: apis.shopSelIndex.method,
			url: domain + apis.shopSelIndex.url,
			data: formData,
			success: function (res) {
				console.log(res);
				if (res.code != 0) {
					if (formList.pages.start > 0) {
						msgPop({msg: res.msg});
					} return
				}
				var h = '', i, d = res.data;
				h += '<option value="">-选择门店-</option>';
				for (i = 0; i < d.length; i ++) {
					h += '<option value="' + d[i].shop_code + '">' + d[i].shop_name + '</option>';
				}
				$('#shopSel').html(h);
			},
			error: function () {
				console.log('网络错误');
			}
		});
	}
</script>